#include <iostream>
#include <memory>
#include "UdpServer.hpp"
#include "Dict.hpp"
#include "InetAddr.hpp"
int main(int argc,char* argv[])
{
    if(argc<2)
    {
        //LOG(Level::FATAL)<<"input error";
        std::cerr<<"Usage"<<argv[0]<<"port"<<std::endl;
        return 1;
    }
    std::string port = argv[1];

    //词典
    Dict dict;
    // auto f = [&](string& word,InetAddr& addr)->string{
    //     return dict.Translate(word,addr);
    // UdpServer us((uint16_t)stoi(port),f);
    // });
    unique_ptr<UdpServer> us = make_unique<UdpServer>((uint16_t)stoi(port),[&](string& word,InetAddr& addr)->string{
        return dict.Translate(word,addr);
    });
    us->Init();
    us->Start();
    return 0;
}